package com.changan.service.impl;

import com.changan.entity.Student;
import com.changan.mapper.StudentMapper;
import com.changan.service.StudentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: StuManagement
 * @description: StudentService实现类
 * @author: Mr.Nie
 * @create: 2021-12-18 13:56
 **/
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    /**
     * 功能描述: <br>
     * 〈查询所有的学生信息〉
     * @Param: []
     * @Return: java.util.List<com.changan.entity.Student>
     * @Author: Mr.Nie
     * @Date: 2021/12/18 13:56
     */
    @Override
    public List<Student> getStudents() {
        return studentMapper.getStudents();
    }

    /**
     * 功能描述: <br>
     * 〈添加学生〉
     * @Param: [student]
     * @Return: int
     * @Author: Mr.Nie
     * @Date: 2021/12/18 14:41
     */
    @Override
    public int addStudent(Student student) {
        return studentMapper.addStudent(student);
    }

    @Override
    public PageInfo<Student> getStuByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Student> students = studentMapper.getStudents();
        PageInfo<Student> pageInfo = new PageInfo<>(students);
        return pageInfo;
    }

    @Override
    public int delStu(Long id) {
        return studentMapper.delStu(id);
    }

    @Override
    public int updStu(Student student) {
        return studentMapper.updStu(student);
    }

    @Override
    public Student getStudentById(Long id) {
        return studentMapper.getStudentById(id);
    }

}
